﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerCareResult.aspx.cs" Inherits="famails.BackEnd.Customer.CustomerCareResult" MasterPageFile="~/Master.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <style>
        #contentjqxgrid {
            width: 100% !important;
        }

        #pagerjqxgrid {
            width: 100% !important;
        }

        #contentjqxgrid_error {
            width: 100% !important;
        }

        #pagerjqxgrid_error {
            width: 100% !important;
        }
    </style>

    <div style="width: 100%; padding: 10px;">

        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="border: 1px solid #333; padding: 0px; padding-bottom: 10px; margin-bottom: 10px;">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold;">
                Thông tin chiến dịch
            </div>
            <asp:Panel ID="pnReport" runat="server">
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: 1px; padding: 0px; border-bottom: 1px solid #333;">
                </div>
                <div style="border-bottom: 1px solid #333; padding: 0px 10px;">
                    <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 0px; margin-top: 10px; border: 1px solid #dedede;">
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 10px 5px; text-align: center; background: #f9f9f9;">
                            <asp:Label ID="lblCampianName" Style="font-size: 16px; line-height: 20px; color: #333; font-weight: bold;" runat="server" Text='<%#Eval("Subject") %>'></asp:Label>
                        </div>
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px;">
                            <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                Email gửi : 
                            </div>
                            <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                <asp:Label ID="lblEmailSend" runat="server" Text='<%#Eval("Email") %>'>&nbsp;</asp:Label>
                            </div>
                        </div>
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; background: #f9f9f9;">
                            <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                Nhóm email nhận : 
                            </div>
                            <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                <asp:Label ID="lblGroupEmailTo" runat="server" Text='<%#Eval("Name") %>'>&nbsp;</asp:Label>
                            </div>
                        </div>
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px;">
                            <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                Bắt đầu : 
                            </div>
                            <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                <asp:Label ID="lblDateStart" runat="server" Text='<%#Eval("StartSend") %>'>&nbsp;</asp:Label>
                            </div>
                        </div>
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; background: #f9f9f9;">
                            <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                Số email gửi : 
                            </div>
                            <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                <asp:Label ID="lblTotalMailSend" runat="server" Text='<%#Eval("TotalSend") %>'>&nbsp;</asp:Label>
                            </div>
                        </div>
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px;">
                            <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                Số email đã mở : 
                            </div>
                            <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                <asp:Label ID="lblOpened" runat="server" Text='<%#Eval("TotalOpen") %>'>&nbsp;</asp:Label>
                            </div>
                        </div>
                        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; background: #f9f9f9;">
                            <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                Số email chưa mở : 
                            </div>
                            <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                <asp:Label ID="lblNotOpen2" runat="server" Text='<%#Eval("TotalNotOpen") %>'>&nbsp;</asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 10px 10px;">
                        <asp:Label ID="lblChart" runat="server" Text="Không có dữ liệu"></asp:Label>
                        <%--<div id="chart_div" style="width: 100%; height: 270px;"></div>--%>
                    </div>
                </div>
            </asp:Panel>
        </div>
        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" id="divList" style="border: 1px solid #333; padding: 0px; margin-bottom: 10px;">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold; position: relative;">
                Thống kê    </div>        
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px; background: #333;">
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                    <label for="simple-input" style="float: left; padding: 10px 20px 0px 0px; font-weight: bolder; font-size: 20px; color: #fff; text-transform: none">
                        Email sống</label>
                </div>
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">

                    <div id="btnExportExcel" style="float: right; margin-right: 10px; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px; border: 1px solid #fff;" class="btn">
                        <span style="margin-right: 10px;" class="fa fa-mail-forward"></span>Xuất dữ liệu
                    </div>

                </div>
            </div>
                <div id='jqxWidget' style="width: 100% !important; font-size: 13px; font-family: Verdana; float: left;">
                    <div id="jqxgrid" style="width: 100% !important;">
                    </div>
                </div>
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px; background: #333;">
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                        <label for="simple-input" style="float: left; padding: 10px 20px 0px 0px; font-weight: bolder; font-size: 20px; color: #fff; text-transform: none">
                            Email Chết</label>
                    </div>
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                        <div id="btnExportExcel_error" style="float: right; margin-right: 10px; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px; border: 1px solid #fff;" class="btn">
                            <span style="margin-right: 10px;" class="fa fa-mail-forward"></span>Xuất dữ liệu
                        </div>

                    </div>
                </div>
                <div id='jqxWidget_error' style="width: 100% !important; font-size: 13px; font-family: Verdana; float: left;">
                    <div id="jqxgrid_error" style="width: 100% !important;">
                    </div>
                </div>

            </div>

        </div>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load("visualization", "1", { packages: ["corechart"] });
            google.setOnLoadCallback(drawChart);
            function drawChart() {
                var data = google.visualization.arrayToDataTable([
             ['Genre', 'Success', 'Faile', { role: 'annotation' }],
             ['Email gửi đi', 95, 5, ''],
             ['Email được mở', 9, 91, ''],
             ['Tình trạng nhận tin', 100, 0, ''],
                ]);

                var options = {
                    width: '100%',
                    height: 250,
                    legend: { position: 'top', maxLines: 3 },
                    bar: { groupWidth: '75%' },
                    isStacked: true,
                };
                // Khai vao biến chèn vào
                var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
                chart.draw(data, options);

            }
        </script>
        <script type="text/javascript">
            function getQueryStrings() {
                var assoc = {};
                var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
                var queryString = location.search.substring(1);
                var keyValues = queryString.split('&');

                for (var i in keyValues) {
                    var key = keyValues[i].split('=');
                    if (key.length > 1) {
                        assoc[decode(key[0])] = decode(key[1]);
                    }
                }

                return assoc;
            }
            jQuery(function ($) {
                $("#btnExportExcel").click(function () {
                    $("#jqxgrid").jqxGrid('exportdata', 'xls', 'registeremaillist');
                });
                var qs = getQueryStrings();
                var id = qs["id"];
                //alert(id);
                $("#jqxgrid").jqxGrid('showloadelement');
                var postValue = "{id:" + id + "}";
                $.ajax({
                    type: "POST",
                    url: "CustomerCareResult.aspx/OpenMailList",
                    data: postValue,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        var source =
                {
                    datatype: "json",
                    datafields: [
                        { name: 'EventId', type: 'int' },
                        { name: 'GroupId', type: 'int' },
                          { name: 'FullName', type: 'string' },
                          { name: 'EmailID', type: 'string' },
                          { name: 'Job', type: 'string' },
                          { name: 'Company', type: 'string' },
                          { name: 'Sex', type: 'string' },
                          { name: 'Phone', type: 'string' },
                          { name: 'Address', type: 'string' },
                        { name: 'CreateDate', type: 'date' }
                    ],
                    id: 'ID',
                    localdata: data,
                    pager: function (pagenum, pagesize, oldpagenum) {
                    }
                };
                        var dataAdapter = new $.jqx.dataAdapter(source);
                        $("#jqxgrid").jqxGrid(
                        {
                            width: $('#divList').width() + 30,
                            source: dataAdapter,
                            selectionmode: 'multiplerowsextended',
                            sortable: true,
                            pageable: true,
                            autoheight: true,
                            columnsresize: true,
                            columns: [
                              { text: 'Họ tên', width: 200, datafield: 'FullName' },
                              { text: 'Email', width: 200, datafield: 'EmailID' },
                              { text: 'Nghề nghiệp', datafield: 'Job' },
                              { text: 'Công ty', datafield: 'Company' },
                              { text: 'Giới tính', datafield: 'Sex' },
                              { text: 'Điện thoại', datafield: 'Phone' },
                              { text: 'Địa chỉ', datafield: 'Address' },
                              { text: 'Thời gian đăng ký', datafield: 'CreateDate', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' }
                            ]
                        });

                    }
                });
            $("#jqxgrid_error").jqxGrid('showloadelement');
            $.ajax({
                type: "POST",
                url: "CustomerCareResult.aspx/ErrorMailList",
                data: postValue,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var source =
            {
                datatype: "json",
                datafields: [
                    { name: 'ID', type: 'decimal' },
                      { name: 'Message', type: 'string' },
                      { name: 'To', type: 'string' },
                      { name: 'Status', type: 'string' },
                    { name: 'SendTime', type: 'date' }
                ],
                id: 'ID',
                localdata: data,
                pager: function (pagenum, pagesize, oldpagenum) {
                }
            };
                    var dataAdapter = new $.jqx.dataAdapter(source);
                    $("#jqxgrid_error").jqxGrid(
                    {
                        width: $('#divList').width() + 30,
                        source: dataAdapter,
                        selectionmode: 'multiplerowsextended',
                        sortable: true,
                        pageable: true,
                        autoheight: true,
                        columnsresize: true,
                        columns: [
                          { text: 'Email', width: 200, datafield: 'To' },
                          { text: 'Thời gian gửi', datafield: 'SendTime', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' },
                          { text: 'Tình trạng', datafield: 'Status', cellsformat: 'F2' },
                          { text: 'Mô tả', datafield: 'Message' }
                        ]
                    });
                }
            });
            });
        </script>
</asp:Content>


